package com.itheima.demo1exception;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ExceptionDemo5 {


    public static void main(String[] args) {
        try {
            test3();
            System.out.println("程序继续执行成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void test3() throws Exception {
        // 编译异常，编译阶段报错，编译不通过
        // 把字符串时间解析成Java中的一个日期对象
        String str = "2025-03-19 11:11:11";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        //Date date = sdf.parse(str); // ParseException 编译时异常
        //通过try...catch...处理
        System.out.println("---------------------------");
        Date date = sdf.parse(str);
        System.out.println(str);
        System.out.println("程序继续执行...");
        InputStream is = new FileInputStream("D:/weixin.jpg");
    }
}
